const mongoose = require('mongoose')

const schema = new mongoose.Schema({
  userid: {
    type: String
  },
  products: [{
    count: {
      type: Number
    },
    product: {
      type: mongoose.SchemaTypes.ObjectId,
      ref: 'ServiceProduct'
    }
  }],
  orderId: {
    type: String
  },
  openid: {
    type: String
  },
  status: {
    type: Number,
    min: 0, //0待支付，支付成功
    max: 2,
    default: 0
  },
  address: {
    type: mongoose.SchemaTypes.ObjectId,
    ref: 'UserAddress'
  }
})

module.exports = mongoose.model('OrderSku', schema)
